<!DOCTYPE html>
<html lang="cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>角色信息 Role Form</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{/statics/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/statics/style/admin.css}" media="all">
    <style type="text/css">
        .field-col-md3{float: left;width: 33%}
        .field-col-md9{float: left;width: 67%}
        .sub-menu-space{margin-left: 15px}
    </style>
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">角色名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入角色名称"
                   class="layui-input" th:value="${role.name}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色代码</label>
        <div class="layui-input-block">
            <input type="text" name="code" lay-verify="required" autocomplete="off" placeholder="请输入角色代码"
                   class="layui-input" th:value="${role.code}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色权限</label>
        <div class="layui-input-block" id="selectitem">
            <div th:each="menu:${menus}">
                <div class='layui-row'>
                    <div class='field-col-md3' style="margin-top: 10px;">
                        <i class='layui-icon' aria-hidden='true'>&#xe655;</i> [[${menu.name}]]
                    </div>
                    <div class='field-col-md9'>
                        <input type='checkbox' th:checked="${permissions != null && #sets.contains(permissions,menu.shiroCode)}?'checked'" class='checkbox' lay-skin='primary'
                               name='permissions[]' th:value='${menu.shiroCode}' title='浏览'>
                    </div>
                </div>
                <div class='layui-row' th:each="sub:${menu.children}">
                    <div class='field-col-md3' style="margin-top: 10px;">
                        <i class='layui-icon sub-menu-space' aria-hidden='true'>&#xe655;</i> [[${sub.name}]]
                    </div>
                    <div class='field-col-md9'>
                        <input type='checkbox' th:checked="${permissions != null && #sets.contains(permissions,sub.shiroCode)}?'checked'" class='checkbox' lay-skin='primary'
                               name='permissions[]' th:value='${sub.shiroCode}' title='浏览'/>
                        <input type='checkbox' th:checked="${permissions != null && #sets.contains(permissions,act.shiroCode)}?'checked'" class='checkbox' lay-skin='primary' th:each="act:${sub.actions}"
                               name='permissions[]' th:value='${act.shiroCode}' th:title='${act.name}'/>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">具体描述</label>
        <div class="layui-input-block">
            <textarea type="text" name="description" autocomplete="off"
                      class="layui-textarea">[[${role.description}]]</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="hidden" name="id" th:value="${role.id}" autocomplete="off" class="layui-input">
        <button class="layui-btn" lay-submit lay-filter="LAY-role-add-submit" id="LAY-role-add-submit">提交</button>
    </div>
</div>

<script th:src="@{/statics/layui/layui.js}"></script>
<script>
    layui.config({
        base: '/statics/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$
            , form = layui.form;
    })
</script>
</body>
</html>